/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import model.dao.util.MySqlDataAccessHelper;
import model.pojo.BrandName;

/**
 *
 * @author TiOc
 */
public class BrandNameDAO 
{
    public static ArrayList<BrandName> getBrandName()
    {
        ArrayList<BrandName> ds = new ArrayList<BrandName>();
        String sql = "SELECT * FROM BrandName As bn WHERE bn.isPublish = '1' order by bn.nameBrandName ASC";
        MySqlDataAccessHelper helper = new MySqlDataAccessHelper();
        helper.open();
        ResultSet rs = helper.executeQuery(sql); 
        try
        {
            while(rs.next())
            {
                BrandName bn = new BrandName();
                bn.setIdBrandName(rs.getInt("idBrandName"));
                bn.setNameBrandName(rs.getString("nameBrandName"));
                bn.setLink(rs.getString("link"));
                bn.setIsPublish(rs.getInt("isPublish"));
                ds.add(bn);
            }
        }
        catch(SQLException ex)
        {
            System.out.println(ex.getMessage());
        }
        helper.close();
        
        return ds;
    }
    
    
}
